<?php
	class bbcode {
	   private $pattern = Array(
        '#\[b\](.*?)\[\/b\]#Siu',
        '#\[img\](.*?)\[\/img\]#Siu'
       );
       private $replacement = Array(
        '<b>$1</b>',
        '<img src="$1" alt="image" />'
       );
       
	   public function parse($string) {
           $string = preg_replace($this->pattern, $this->replacement, $string);
           return $string;
	   }
	}
?>